package jobs;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.aton.job.BaseJob;

import models.WdShareTask;
import models.WdTask;
import play.jobs.Every;

/**
 * 
 * 微代分享任务自动处理程序<br />
 * 
 * 
 * @author zhiyuan
 * @version v1.0
 * @since 2017年3月31日 上午7:21:59
 */
@Every("1min")
public class WdShareProcessJob extends BaseJob {
	public static final Logger log = LoggerFactory.getLogger(WdShareProcessJob.class);

	@Override
	public void doJob() throws Exception {
		List<WdShareTask> list = WdShareTask.listOverdueTask();
		for(WdShareTask task : list){
			WdShareTask.cancelWdTask(task.id, task.buyerId);
		}

		List<WdShareTask> finishShareTaskList = WdShareTask.listFinishedTask();
		for(WdShareTask task : finishShareTaskList){
			task.finishTask();
		}

		//更新分享任务状态为已提交待审核
		WdShareTask.updateLiveTaskStatus();

		super.doJob();
	}
}
